package com.smalls.newvideotwo.utils;

import android.app.ActivityManager;
import android.app.ActivityManager.MemoryInfo;
import android.content.Context;
import android.support.v4.media.session.PlaybackStateCompat;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;


public class MemInfo {
    public static long getmem_UNUSED(Context mContext) {
        ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
        MemoryInfo mi = new MemoryInfo();
        am.getMemoryInfo(mi);
        return mi.availMem / PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID;
    }

    public static long getmem_TOLAL() {
        FileNotFoundException var16;
        Throwable th;
        IOException var17;
        String content = null;
        BufferedReader br = null;
        try {
            BufferedReader br2 = new BufferedReader(new FileReader("/proc/meminfo"), 8);
            try {
                String begin = br2.readLine();
                if (begin != null) {
                    content = begin;
                }
                if (br2 != null) {
                    try {
                        br2.close();
                        br = br2;
                    } catch (IOException var15) {
                        var15.printStackTrace();
                        br = br2;
                    }
                }
            } catch (FileNotFoundException e) {
                var16 = e;
                br = br2;
                try {
                    var16.printStackTrace();
                    if (br != null) {
                        try {
                            br.close();
                        } catch (IOException var152) {
                            var152.printStackTrace();
                        }
                    }
                    if (content != null) {
                    }
                    return 0;
                } catch (Throwable th2) {
                    th = th2;
                    if (br != null) {
                        try {
                            br.close();
                        } catch (IOException var1522) {
                            var1522.printStackTrace();
                        }
                    }
                }
            } catch (IOException e2) {
                var17 = e2;
                br = br2;
                var17.printStackTrace();
                if (br != null) {
                    try {
                        br.close();
                    } catch (IOException var15222) {
                        var15222.printStackTrace();
                    }
                }
                if (content != null) {
                }
                return 0;
            } catch (Throwable th3) {
                th = th3;
                br = br2;
                if (br != null) {
                    br.close();
                }
            }
        } catch (FileNotFoundException e3) {
            var16 = e3;
            var16.printStackTrace();
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (content != null) {
            }
            return 0;
        } catch (IOException e4) {
            var17 = e4;
            var17.printStackTrace();
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (content != null) {
            }
            return 0;
        }
        if (content != null || content.equals("")) {
            return 0;
        }
        return (long) Integer.parseInt(content.substring(content.indexOf(58) + 1, content.indexOf(107)).trim());
    }
}
